home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
SourceCode
/
Tutorial
/
Cookbook
/
32.Math
/
rand.c
< prev
Wrap
C/C++ Source or Header
|
1992-12-19
|
295b
|
17 lines
#include <libc.h>
#include <sys/time.h>
#define MAXRND 2147483649
extern long random();
extern void srandom();
int getRand(int MaxVal)
{
struct timeval tp;
struct timezone tzp;
gettimeofday(&tp, &tzp);
srandom((int) tp.tv_usec );
return(MaxVal * ((float) random()/(float) MAXRND) + 1 );
}